package com.cari.oa.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cari.oa.dao.AttachmentDao;
import com.cari.oa.dao.BaseDao;
import com.cari.oa.domain.AttachmentEntity;
@Service
public class AttachmentService extends BaseService<AttachmentEntity> {
	public static Integer PROJECT_ATTACHMENT_TYPE = 1;		//项目记录的附件类型
	public static Integer COST_ATTACHMENT_TYPE = 2;	   		//费用记录的附件类型
	public static Integer REQ_ATTACHEMENT_TYPE = 3;			//需求的附件类型
	public static Integer BUG_ATTACHEMENT_TYPE = 4;			//需求的附件类型
	public static Integer OA_REPOSITORY_ATTACHEMENT_TYPE = 5;	//OA知识库附件类型

	@Resource
	private AttachmentDao attachmentDao;
	
	@Override
	public BaseDao<AttachmentEntity> getDao() {
		return attachmentDao;
	}

	@Transactional(readOnly=true)
	public List<AttachmentEntity> getPage(String uploadUser, String attachName, 
			String path, String objectid, String type, int page, int size){
		return attachmentDao.getPage(uploadUser, attachName, path, objectid, type, page, size);
	}

	@Transactional(readOnly=true)
	public List<AttachmentEntity> getAttachments(String uploadUser, String attachName, 
			String path, String objectId, String type){
		return attachmentDao.getAttachments(uploadUser, attachName, path, objectId, type);
	}
	
	@Transactional(readOnly=true)
	public long getCount(String uploadUser, String attachName, 
			String path, String objectid, String type){
		return attachmentDao.getCount(uploadUser, attachName, path, objectid, type);
	}

	public List<AttachmentEntity> getByObjectId(String id) {
		
		return attachmentDao.getByObjectId(id);
	}
}
